package com.hong.chapter3;

import java.util.Arrays;

/**
 * Created by hong on 2018/5/28.
 * 线和组相关属性
 */
public class CreateThread2 {

    public static void main(String[] args) {
        Thread t = new Thread();
        t.start();
        //System.out.println(t.getThreadGroup());
        //System.out.println(Thread.currentThread().getName());
        //System.out.println(Thread.currentThread().getThreadGroup().getName());
        ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
        /*返回此线程组及其子组中活动线程数的估计。*/
        System.out.println(threadGroup.activeCount());
        Thread[] threads = new Thread[threadGroup.activeCount()];
        /*复制到该线程组及其子组中每个活动子组的指定数组引用。 */
        threadGroup.enumerate(threads);
        /*打印线程组中所有线程*/
        Arrays.asList(threads).forEach(System.out::println);
        /*for (Thread temp:threads) {
            System.out.println(temp);
        }*/

    }
}
